/*
 * Copyright (c) 2011 Team A CS2340. All rights reserved.
 */

package edu.gatech.teama.doctorsoffice.model;

import java.io.IOException;
import java.io.Serializable;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Address.java
 * representation of a street address that divides the address
 * into several parts
 * @author Team A
 * @version 1.0
 *
 */
public class Address extends AbstractModelObject implements Serializable {
	
	/**
	 * Street number
	 */
	//private int streetNum;  
	
	/**
	 * Street name
	 */
	private String streetName;
	
	/**
	 * Zip code
	 */
	private String zipcode;
	
	/**
	 * City
	 */
	private String city;
	
	/**
	 * State
	 */
	private String state;
	
	/**
	 * Logger for all <code>Address</code> instances.
	 */
	private static final Logger LOGGER =
		Logger.getLogger("edu.gatech.teama.doctorsoffice.model.Address");

	static {
		FileHandler fh = null;
		try {
			fh = new FileHandler("application.log");
		} catch (SecurityException e) {
			LOGGER.log(Level.SEVERE,
					"Security Exception creating the logger file handler");
			LOGGER.throwing("ClientMessageHandler", "static", e);
		} catch (IOException e) {
			LOGGER.log(Level.SEVERE, "IO Exception creating the logger file handler");
			LOGGER.throwing("ClientMessageHandler", "static", e);
		}

		LOGGER.addHandler(fh);
		LOGGER.setLevel(Level.ALL);
	}

    /**
	 *  Constructor assigning street, zip code, city, and state
	 *  @param streetName
	 *  @param zipcode
	 *  @param city
	 *  @param state
	 */
	public Address(String streetName, String zipcode, String city, 
			String state){
		//this.streetNum = streetNum;
		this.streetName = streetName;
		this.zipcode = zipcode;
		this.city = city;
		this.state = state;
		LOGGER.info("New Address: " + streetName + " " + city
				+ " " + state + " " + zipcode);
	}
	
	/**
	 *  Constructor assigning zip code, city, and state
	 *  @param zipcode
	 *  @param city
	 *  @param state
	 */
	public Address(String zipcode, String city, String state){
		this.zipcode = zipcode;
		this.city = city;
		this.state = state;
		LOGGER.info("New Address: " + city + " " + state + " " + zipcode);
	}
	
	/**
	 * Answers request for the number in the street address
	 * @return streetNum 
	 */
	 /*public int getStreetNum(){
		return this.streetNum;
	}*/

	/**
	 * Changes street number to parameter street number
	 * @param streetNum
	 */ 
	/*public void setStreetNum(int streetNum){
		this.streetNum = streetNum;
	}*/
	
	/**
	 * Answers request for the street in the street address
	 * @return streetName */ 
	public String getStreetName(){
		return this.streetName;
	}
	
	/**
	 * Changes street name to parameter street name
	 * @param streetName
	 * 
	 */
	public void setStreetName(String streetName){
		this.streetName = streetName;
	}
	
	/**
	 * Answers request for the zip code
	 * @return zipcode */ 
	public String getZipcode(){
		return this.zipcode;
	}
	
	/**
	 * Changes zip code to parameter zip code
	 * @param zipcode
	 */
	public void setZipcode(String zipcode){
		this.zipcode = zipcode;
	}
	
	/**
	 * Answers request for the city
	 * @return city */ 
	public String getCity(){
		return this.city;
	}
	
	/**
	 * Changes city to parameter city
	 * @param city
	 */
	public void setCity(String city){
		this.city = city;
	}

	/**
	 * Answers request for the state
	 * @return state */ 
	public String getState(){
		return this.state;
	}
	
	/**
	 * Changes state to parameter state
	 * @param state
	 */
	public void setState(String state){
		this.state = state;
	}

	/**
	 * Creates text compilation of address variables
	
	 * @return "complete address" */
	public String toString() {
		return "" + streetName + "\n"
			+ city + " " + state + " " + zipcode;
	}
	
	/**
	 * get line1
	 * @return getStreetName
	 */
	public String getLine1() {
		return this.getStreetName();
	}
	
	/**
	 * get line2
	 * @return city + state + zipcode
	 */
	public String getLine2() {
		return this.getCity() + ", " + this.getState() + " " + this.getZipcode();
	}
}
